#include <bits/stdc++.h>
using namespace std;

using llt = long long;
using vi = vector<int>;
using pii = pair<int, int>;

void work(){
    int a, b; cin >> a >> b;
    cout << a + (b <= a / 2 ? b : a / 2) << endl; 
    return;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int nofkase = 1;
    // cin >> nofkase;
    while(nofkase--) work();
    return 0;
}
